function addHandler(element, type, handler) {
    if(element.addEventListener) {
        element.addEventListener(type, handler, false)
    } else if(element.attachEvent) {
        element.attachEvent('on' + type, handler)
    } else {
        element["on" + type] = handler
    }
}


function addHandler(element, type, handler) {
    if(element.addEventListener){
        addHandler = function(element, type, handler){
            element.addEventListener(type, handler, false)
        }
    }else if (element.attachEvent){
        addHandler = function(element, type, handler){
            element.attachEvent("on" + type, handler)
        }
    }else{
        addHandler = function(element, type, handler){
            element["on" + type] = handler
        }
    }
    return addHandler(element, type, handler)
}


const addHandler = (function(){
    if(document.addEventListener) {
        return function(element, type, handler){
            element.addEventListener(type, handler, false)
        }
    }else if (document.attachEvent){
        return function(element, type, handler){
            element.attachEvent('on' + type, handler)
        }
    }else{
        return function(element, type, handler){
            element["on" + type] = handler
        }
    }
})()